
// ignore_for_file: non_constant_identifier_names

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:verse_systems/res/colors.dart';
import 'package:verse_systems/utils/image_utils.dart';
import 'package:verse_systems/widgets/drawer_appbar.dart';

enum LoantType {
  loanamount,
  loanhalf,
}

class CustomLoanAmountAppbar extends StatelessWidget {
  final LoantType amountType;
  final String? amount; 
  final String? time;
  const CustomLoanAmountAppbar(
      {super.key, this.amountType = LoantType.loanamount,  this.time,  this.amount});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 300.w,
      width: MediaQuery.of(context).size.width,
      decoration: BoxDecoration(
        color: Colours.app_main_color,
        image: DecorationImage(
            image: ExactAssetImage(ImageUtils.getImgPath("loan_background")),
            fit: BoxFit.fill),
      ),
      child: Column(
        children: [
        DrawerAppbar(
            backgroundColor: Colors.transparent,
            color: Colours.app_main_color,
            title: 'loan'.tr,
          ),
          Container(
            child:(amountType == LoantType.loanamount) ? loan_amount : loan_half,
          ),
          loan_text
        ],
      ),
    );
  }

  Widget get loan_half {
    return Container(
        height: 164.w,
        width: 141,
        decoration: BoxDecoration(
          image: DecorationImage(
              image: ExactAssetImage(ImageUtils.getImgPath("loan_half")),
              fit: BoxFit.contain),
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              margin: EdgeInsets.only(top: 20.w),
              child: Text(
                "amount_borrowed".tr,
                textAlign: TextAlign.center,
                style: TextStyle(
                  fontSize: 14.sp,
                  color: Colours.app_main_color,
                ),
              ),
            ),
            Text(
             amount== ""? "":amount.toString(),
              textAlign: TextAlign.center,
              style: TextStyle(
                fontSize: 36.sp,
                color: Colours.app_orange_text_color,
                fontWeight: FontWeight.w600,
                letterSpacing: -5.sp,
              ),
            ),
            Text(
             time == "" ? "":"${"term_loan".tr}:${time.toString()}天",
              textAlign: TextAlign.center,
              style: TextStyle(
                  fontSize: 10.sp,
                  color: Colours.app_orange_text_color,
                  fontWeight: FontWeight.w600),
            )
          ],
        ));
  }

  Widget get loan_text {
    return Text(
      (amountType == LoantType.loanamount) ? "apply_loan_accept_amount".tr : "",
      textAlign: TextAlign.center,
      style: TextStyle(
        fontSize: 12.sp,
        color: Colours.app_orange_text_color,
      ),
    );
  }

  Widget get loan_amount {
    return Container(
        height: 164.w,
        width: 141,
        decoration: BoxDecoration(
          image: DecorationImage(
            image: ExactAssetImage(ImageUtils.getImgPath("loan_amount")),
          ),
        ),
        alignment: const Alignment(0.0, 0.1),
        child: Text(
          "${"system_will_do".tr}\n${"automatically_match".tr}",
          textAlign: TextAlign.center,
          style: TextStyle(
            fontSize: 14.sp,
            color: Colours.app_main_color,
          ),
        ));
  }
}
